<!DOCTYPE html>
<html class="no-js">
<head lang="en">

    <#include "../head_import.html" />
    <style type="text/css">
        .method-div{padding:2px 1px;}
        .hidden{display:none;}
        .country-price{border:1px solid #ccc;padding:2px;margin:2px 0px;}
    </style>
</head>
<body>
<#include "../include/top_nav.html">
    <div class="am-cf admin-main">

        <!-- sidebar start -->
        <#include "../config/left.html">
            <!-- sidebar end -->
            <!-- content start-->
            <div class="admin-content">
                <div class="am-cf am-padding">
                    <div class="am-fl am-cf"><@s.m "global.position"/>: <@s.m "shipping.function"/> - <@s.m "global.add"/></div>
                </div>
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-sm-centered">
                        <form class="ropt">
                            <input type="submit" value="<@s.m "global.backToList"/>" onclick="this.form.action='list.do';"/>
                        </form>
                        <div class="clear"></div>
                    </div>
                </div>
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-sm-centered">
                        <@p.form id="baseForm" action="o_save.do">
                        <@p.text label="shipping.name" name="name" required="true" class="required" size="40" maxlength="150"/>
                        <@p.select  label="物流公司" name="logisticsId"  list=list listKey="id" listValue="name" required="true"/>
                        <@p.select  label="物流类型" name="logisticsType" required="true" list={"EXPRESS":"快递","POST":"平邮","EMS":"EMS"} />
                        <@p.td label="shipping.method" required="true">
                        <@p.radio name="method" required="true" value="1" list={"1":"shipping.uniformPrice","2":"shipping.byWeight"} onclick="methodChange();"/>
                        <div id="uniformDiv" class="method-div hidden"><@s.m "shipping.uniformPrice"/>: <input type="text" name="uniformPrice" vld="{required:function(){var m=$('input[name=method]:checked').val(); return m=='1';},number:true,maxlength:20}"/></div>
                        <div id="weightDiv" class="hidden">
                            <div class="method-div"><@s.m "shipping.firstWeight"/>: <input type="text" name="firstWeight" vld="{required:function(){var m=$('input[name=method]:checked').val(); return m=='2'||m=='3';},digits:true,maxlength:10}" size="7"/> g &nbsp; <@s.m "shipping.additionalWeight"/>: <input type="text" name="additionalWeight" vld="{required:function(){var m=$('input[name=method]:checked').val(); return m=='2'||m=='3';},digits:true,maxlength:10}" size="7"/> g</div>
                            <div class="method-div"><@s.m "shipping.firstPrice"/>: <input type="text" name="firstPrice" vld="{required:function(){var m=$('input[name=method]:checked').val(); return m=='2'||m=='3';},number:true,maxlength:20}" size="7"/> &nbsp; &nbsp; <@s.m "shipping.additionalPrice"/>: <input type="text" name="additionalPrice" vld="{required:function(){var m=$('input[name=method]:checked').val(); return m=='2'||m=='3';},number:true,maxlength:20}" size="7"/></div>
                        </div>
                    </@p.td><@p.tr/>
                    <@p.text label="shipping.priority" name="priority" required="true" value="10" class="required digits" size="7" maxlength="10"/>
                    <@p.radio label="shipping.disabled" name="disabled" required="true" value="false" list={"false":"global.true","true":"global.false"}/>
                    <@p.radio label="是否默认" name="isDefault" list={"true":"global.true","false":"global.false"} value="false" required="true" class="required"/>
                    <@p.textarea label="shipping.description" name="description" cols="70" rows="3" maxlength="255"/>
                    <@p.td><@p.submit code="global.submit"/> &nbsp; <@p.reset code="global.reset"/></@p.td>
            </@p.form>
            </div>
    </div>
    <div class="am-g">
        <div class="am-u-sm-12 am-u-sm-centered">
            <textarea id="tpl" style="display:none">
                <div id="cp{0}" class="country-price">
                    <div><@s.m "shipping.firstPrice"/>: <input type="text" name="firstPrice{0}" vld="{required:function(){var m=$('input[name=method]:checked').val(); return m=='3';},number:true,maxlength:20}" size="7"/> &nbsp; &nbsp; <@s.m "shipping.additionalPrice"/>: <input type="text" name="additionalPrice{0}" vld="{required:function(){var m=$('input[name=method]:checked').val(); return m=='3';},number:true,maxlength:20}" size="7"/> &nbsp; <input type="button" value="<@s.m "shipping.deleteLine"/>" onclick="$('#cp{0}').remove();"/></div>
                </div>
            </textarea>
        </div>
    </div>

    </div>

    </div>

<script type="text/javascript">
$(function() {
	methodChange();
	$("#baseForm").validate();
});
function methodChange() {
var method = $("input[name=method]:checked").val();
if(method=="1") {
	$('#uniformDiv').show();
	$('#weightDiv').hide();
}else if(method=="2") {
	$('#uniformDiv').hide();
	$('#weightDiv').show();
}
return true;
}
var index=1;
function appendLine() {
	var s = $.format($('#tpl').val(),index);
	index++;
	$('#cps').append(s);
}
</script>

</body>
</html>